package remote.mvc.controls
{
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;
	
	import remote.mvc.events.CallBackEvent;
	
	
	/**
	 * 回调时的调度器，成功获取数据后，回调时使用
	 * @createDate 2011-2-28
	 * @author 徐俊杰
	 */
	public class CallBackDispatcher extends EventDispatcher
	{
		
		private static var _instance:CallBackDispatcher;
		
		/**
		 * 回调调度器单例
		 * 
		 */		
		public static function get instance():CallBackDispatcher
		{
			if(_instance == null)
				_instance = new CallBackDispatcher();
			return _instance;
		}
		
		/**
		 * 添加回调事件监听 
		 * @param target 监听对象
		 * @param oriType 原始类型
		 * @param listener 处理方法
		 * 
		 */		
		public static function addListener(target:IEventDispatcher, oriType:String, listener:Function):void
		{
			target.addEventListener(CallBackEvent.createCallBackEventType(oriType), listener);
		}
		
		/**
		 * 移除回调事件监听
		 * @param target 监听对象
		 * @param oriType 原始类型
		 * @param listener 处理方法
		 * 
		 */		
		public static function removeListener(target:IEventDispatcher, oriType:String, listener:Function):void
		{
			target.removeEventListener(CallBackEvent.createCallBackEventType(oriType), listener);
		}
		
		public function CallBackDispatcher(target:IEventDispatcher=null)
		{
			super(target);
		}

	}
}